package com.example.kaogong.sys.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.kaogong.sys.pojo.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.kaogong.sys.pojo.UserLike;
import com.example.kaogong.sys.pojo.vo.PostCommentVo;
import com.example.kaogong.sys.pojo.vo.PostVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 评论 Mapper 接口
 * </p>
 *
 * @author    
 * @since 2022-03-26
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {

    Page<PostCommentVo> getPostComment(@Param("page") Page<Comment> commentPage, @Param("postId") Integer postId, @Param("cid") Integer cid);

    @Update({"update t_comment set content = '该评论已被屏蔽' where cid = #{commentId}"})
    int shieldComment(Integer commentId);

    @Update({"update t_comment set `like` = `like` + 1\n" +
            "where cid = #{commentId}"})
    int likeComment(Integer commentId);

    int insertUserPostCommentLike(UserLike userLike);
}
